package spring.cloud.tasks.api.domain.zooKeeperClusterAndNameSpace;


import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Setter
@Getter
public class ZooKeeperCluster {

    private String zooKeeperClusterKey;
    private String zooKeeperAddressList;
    private String digest;
    private String description;


    private boolean offline = false;

    public ZooKeeperCluster(String zooKeeperClusterKey, String zooKeeperAddressList, String digest, String description) {
        this.zooKeeperClusterKey = zooKeeperClusterKey;
        this.zooKeeperAddressList = zooKeeperAddressList;
        this.digest = digest;
        this.description = description;
    }


    private List<NameSpaceConfiguration> nameSpaceConfigurationList = new ArrayList<NameSpaceConfiguration>();


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof ZooKeeperCluster)) {
            return false;
        }

        ZooKeeperCluster zooKeeperCluster = (ZooKeeperCluster) o;

        if (zooKeeperClusterKey != null ? !zooKeeperClusterKey.equals(zooKeeperCluster.zooKeeperClusterKey) : zooKeeperCluster.zooKeeperClusterKey != null) {
            return false;
        }
        if (zooKeeperAddressList != null ? !zooKeeperAddressList.equals(zooKeeperCluster.zooKeeperAddressList) : zooKeeperCluster.zooKeeperAddressList != null) {
            return false;
        }
        if (description != null ? !description.equals(zooKeeperCluster.description) : zooKeeperCluster.description != null) {
            return false;
        }
        return digest != null ? digest.equals(zooKeeperCluster.digest) : zooKeeperCluster.digest == null;

    }


    @Override
    public int hashCode() {
        int result = zooKeeperClusterKey != null ? zooKeeperClusterKey.hashCode() : 0;
        result = 31 * result + (zooKeeperAddressList != null ? zooKeeperAddressList.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (digest != null ? digest.hashCode() : 0);
        return result;
    }
}
